﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.Framework.Data;

namespace Com.Library.DB.Event
{
	public class EventModel
	{
		public static void Create(string EventStart, string EventEnd, string PublicationDate, string ImageUrl, string BigImageUrl, string Title, string Content, bool Show, string ManagerName,
			string BigImageUrl2, string BigImageUrl3, string BigImageUrl4, string BigImageUrl5, string BigImageUrl6, string BigImageUrl7, string BigImageUrl8, string BigImageUrl9, string BigImageUrl10,
			byte CodeContent
			)
		{
			EventCreateArguments args = new EventCreateArguments()
			{
				strEventStart = EventStart,
				strEventEnd = EventEnd,
				strPublicationDate = PublicationDate,
				strImageUrl = ImageUrl,
				strBigImageUrl = BigImageUrl,
				strTitle = Title,
				strContent = Content,
				isShow = Show,
				strManagerName = ManagerName,

				strBigImageUrl2 = BigImageUrl2,
				strBigImageUrl3 = BigImageUrl3,
				strBigImageUrl4 = BigImageUrl4,
				strBigImageUrl5 = BigImageUrl5,
				strBigImageUrl6 = BigImageUrl6,
				strBigImageUrl7 = BigImageUrl7,
				strBigImageUrl8 = BigImageUrl8,
				strBigImageUrl9 = BigImageUrl9,
				strBigImageUrl10 = BigImageUrl10,
				CodeContent = CodeContent,
			};

			EventCreate sp = new EventCreate();
			sp.SetArguments(args);

			sp.ExecuteNonQuery();
		}

		public static ListData<EventEntity, OutputEntity> GetList(bool? _CurrentOlny, bool? isShow, int PageNo, byte PageSize)
		{
			EventGetListArguments args = new EventGetListArguments()
			{
				_isCurrentOnly = _CurrentOlny.HasValue?_CurrentOlny.Value:true,
                isShow = isShow,
				PageNo = PageNo,
				PageSize = PageSize
			};

			EventGetList sp = new EventGetList();
			sp.SetArguments(args);
			List<EventEntity> list = sp.Execute();
			OutputEntity output = sp.GetOutput();
			return new ListData<EventEntity, OutputEntity>(list, output);
		}

		public static void Modify(int EventSN, string EventStart, string EventEnd, string PublicationDate, string ImageUrl, string BigImageUrl, string Title, string Content, bool? Show, string ManagerName,
			string BigImageUrl2, string BigImageUrl3, string BigImageUrl4, string BigImageUrl5, string BigImageUrl6, string BigImageUrl7, string BigImageUrl8, string BigImageUrl9, string BigImageUrl10, byte CodeContent
			)
		{
			EventModifyArguments args = new EventModifyArguments()
			{
				n4EventSN = EventSN,
				strEventStart = EventStart,
				strEventEnd = EventEnd,
				strPublicationDate = PublicationDate,
				strImageUrl = ImageUrl,
				strBigImageUrl = BigImageUrl,
				strTitle = Title,
				strContent = Content,
				isShow = Show,
				strManagerName = ManagerName,

				strBigImageUrl2 = BigImageUrl2,
				strBigImageUrl3 = BigImageUrl3,
				strBigImageUrl4 = BigImageUrl4,
				strBigImageUrl5 = BigImageUrl5,
				strBigImageUrl6 = BigImageUrl6,
				strBigImageUrl7 = BigImageUrl7,
				strBigImageUrl8 = BigImageUrl8,
				strBigImageUrl9 = BigImageUrl9,
				strBigImageUrl10 = BigImageUrl10,
				CodeContent = CodeContent,
			};

			EventModify sp = new EventModify();
			sp.SetArguments(args);
			sp.ExecuteNonQuery();
		}

		public static EventEntity GetInfo(int EventSN)
		{
			EventGetInfoArguments args = new EventGetInfoArguments()
			{
				n4EventSN = EventSN,
			};

			EventGetInfo sp = new EventGetInfo();
			sp.SetArguments(args);

			EventEntity info = sp.ExecuteNonQuery();

			return info;
		}

		public static void Remove(int EventSN)
		{
			EventRemoveArguments args = new EventRemoveArguments()
			{
				n4EventSN = EventSN
			};

			EventRemove sp = new EventRemove();
			sp.SetArguments(args);

			sp.ExecuteNonQuery();
		}

		public static EventMoveEntity GetMoveInfo(int EventSN)
		{
			EventGetInfoMoveNoArguments arg = new EventGetInfoMoveNoArguments();
			arg.n4EventSN = EventSN;

			EventGetInfoMoveNo sp = new EventGetInfoMoveNo();
			sp.SetArguments(arg);
			EventMoveEntity info = sp.ExecuteNonQuery();
			return info;
		}

		public static ListData<EventCommentEntity, OutputEntity> CommentGetList(int EventSN, int PageNo, byte PageSize)
		{
			EventCommentGetListArguments arg = new EventCommentGetListArguments();
			arg.n4EventSN = EventSN;
			arg.PageNo = PageNo;
			arg.PageSize = PageSize;

			EventCommentGetList sp = new EventCommentGetList();
			sp.SetArguments(arg);
			List<EventCommentEntity> list = sp.Execute();
			OutputEntity output = sp.GetOutput();

			return new ListData<EventCommentEntity, OutputEntity>(list, output);
		}

		public static void CommentCreate(int EventSN, int UserNo, string UserID, string UserName, string UserIP, string Comment)
		{
			EventCommentCreateArguments arg = new EventCommentCreateArguments();
			arg.n4EventSN = EventSN;
			arg.n4UserNo = UserNo;
			arg.strUserID = UserID;
			arg.strUserName = UserName;
			arg.strUserIP = UserIP;
			arg.strComment = Comment;
			EventCommentCreate sp = new EventCommentCreate();
			sp.SetArguments(arg);
			sp.Execute();
		}

		public static void CommentRemove(int EventCommentSN)
		{
			EventCommentRemoveArguments arg = new EventCommentRemoveArguments();
			arg.n4EventCommentSN = EventCommentSN;

			EventCommentRemove sp = new EventCommentRemove();
			sp.SetArguments(arg);
			sp.Execute();
		}

		public static void CommentRestore(int EventCommentSN)
		{
			EventCommentRestoreArguments arg = new EventCommentRestoreArguments();
			arg.n4EventCommentSN = EventCommentSN;

			EventCommentRestore sp = new EventCommentRestore();
			sp.SetArguments(arg);
			sp.Execute();
		}

		public static void CommentModify(int EventCommentSN, string Comment, string UserIP)
		{
			EventCommentModifyArguments arg = new EventCommentModifyArguments();
			arg.n4EventCommentSN = EventCommentSN;
			arg.strComment = Comment;
			arg.strUserIP = UserIP;

			EventCommentModify sp = new EventCommentModify();
			sp.SetArguments(arg);
			sp.ExecuteNonQuery();
		}

		public static ListData<EventCommentWriterEntity, OutputEntity> CommentWriterGetList(int EventSN, int PageNo, byte PageSize)
		{
			EventCommentWriterGetListArguments arg = new EventCommentWriterGetListArguments();
			arg.n4EventSN = EventSN;
			arg.PageNo = PageNo;
			arg.PageSize = PageSize;

			EventCommentWriterGetList sp = new EventCommentWriterGetList();
			sp.SetArguments(arg);
			List<EventCommentWriterEntity> list = sp.Execute();
			OutputEntity output = sp.GetOutput();

			return new ListData<EventCommentWriterEntity, OutputEntity>(list, output);
		}

		public static ListData<MyEventEntity, OutputEntity> MyEventGetList(int UserNo, int PageNo, byte PageSize)
		{
			MyEventGetListArguments arg = new MyEventGetListArguments();
			arg.n4UserNo = UserNo;
			arg.PageNo = PageNo;
			arg.PageSize = PageSize;

			MyEventGetList sp = new MyEventGetList();
			sp.SetArguments(arg);
			List<MyEventEntity> record = sp.Execute();
			OutputEntity output = sp.GetOutput();

			return new ListData<MyEventEntity, OutputEntity>(record, output);
		}
	}
}
